package com.fisherman.bean;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanPostProcessor;
import org.springframework.stereotype.Component;

/**
 * @User: fisherman
 * @Date: 2020/5/21 9:34
 *
 * 后置处理器：初始化前后进行工作
 * 将后置处理器加入容器中
 */
@Component
public class MyBeanPostProcessor implements BeanPostProcessor {

    public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
        System.out.println("postProcessBeforeInitialization在初始化之前工作"+beanName+"=>"+bean);
        return bean;
    }

    public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
        System.out.println("postProcessBeforeInitialization在初始化之后工作"+beanName+"=>"+bean);
        return bean;
    }
}
